from django.contrib import admin
from app import models


# Register your models here.
class UserAdmin(admin.ModelAdmin):
    list_display = ("user_name", "status", "phone")
    search_fields = ["user_name"]
    list_filter = ["user_name"]


admin.site.register(models.User, UserAdmin)


class AddressAdmin(admin.ModelAdmin):
    list_display = ("user_name", "phone", "address", "is_default")
    search_fields = ["user"]
    list_filter = ["user"]


admin.site.register(models.Address, AddressAdmin)


class GoodsAdmin(admin.ModelAdmin):
    list_display = ("good_name", "ing_url", "price", "intro", "unit")
    search_fields = ["good_name"]
    list_filter = ["good_name"]
    filter_horizontal = ['type']


admin.site.register(models.Goods, GoodsAdmin)


class TypeAdmin(admin.ModelAdmin):
    list_display = ("id","type_name","title_img")
    search_fields = ["type_name"]
    list_filter = ["type_name"]


admin.site.register(models.Type, TypeAdmin)


class OrderAdmin(admin.ModelAdmin):
    list_display = ("order_no", "status", "time", "user_name", "phone", "address", "total_price", "pay_status")
    search_fields = ["order_no"]
    list_filter = ["order_no"]


admin.site.register(models.Order, OrderAdmin)


class OrderDetailAdmin(admin.ModelAdmin):
    list_display = ("good_name", "price", "num", "ing_url", "total_price")
    search_fields = ["good_name"]
    list_filter = ["good_name"]


admin.site.register(models.OrderDetail, OrderDetailAdmin)


class CartAdmin(admin.ModelAdmin):
    list_display = ("num","user")
    search_fields = ["num"]
    list_filter = ["num"]


admin.site.register(models.Cart, CartAdmin)
